home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / patch / ppak25_1.lha / PhonePak_2.5 / rexxDayNight.ppak < prev    next >
Text File  |  1994-10-26  |  5KB  |  114 lines

  1. /****************************************************************************/
  2. /*  DayNight.ppak 10/26/94 Copyright 1994 Atlantis Design Group, Inc.       */
  3. /*  PhonePak ARexx script for Day/Night system - install in REXX:           */
  4. /*                                                                          */
  5. /*  To use this script, set the constants (below) to your particular        */
  6. /*  environment.  Then, add an item to the schedule with the group name set */
  7. /*  to "DayNight".  The date and time should be set to when you want the    */
  8. /*  first transition to occur.  This script will remain active in the       */
  9. /*  schedule forever.                                                       */
  10. /*                                                                          */
  11. /*  When this script is initially scheduled, or upon system reboot, it will */
  12. /*  figure out whether to transition to the day or night system depending   */
  13. /*  on whether the current time is before or after noon.  The night system  */
  14. /*  will be used on weekends.                                               */
  15. /*                                                                          */
  16. /*  This script is designed to change the main setup for each line.         */
  17. /****************************************************************************/
  18.  
  19. /***************/
  20. /*  Constants  */
  21. /***************/
  22.  
  23. DaySystem = 'Day'           /* Name of AM system */
  24. NightSystem = 'Night'       /* Name of PM system */
  25. GoToDay = 900               /* Time to go to day system in military HHMM */
  26. GoToNight = 1700            /* Time to go to night system in military HHMM */
  27. NumLines = 2                /* Number of PhonePaks installed */
  28.  
  29. /****************************************************************************/
  30.  
  31. TryAgain = FALSE
  32.  
  33. /**************************************/
  34. /*  Figure out which system to go to  */
  35. /**************************************/
  36.  
  37. TargetSystem = GetClip(TargetSystem)    /* Set variable to clip value */
  38.  
  39. if TargetSystem = '' then do            /* First time execution */
  40.     CurrentDay = Date('w')              /* Retrieve day of week */
  41.     if CurrentDay = 'Saturday' | CurrentDay = 'Sunday' then
  42.         TargetSystem = NightSystem
  43.     else do
  44.         CurrentTime = Time('m')             /* Retrieve minutes since midnight */
  45.         if CurrentTime > 719 then
  46.             TargetSystem = NightSystem
  47.         else
  48.             TargetSystem = DaySystem
  49.         Call SetClip(TargetSystem, TargetSystem)
  50.         end
  51.     end
  52.  
  53.  
  54. /******************************************/
  55. /*  Attempt to change the system(s) over  */
  56. /******************************************/
  57.  
  58. do x=1 to NumLines
  59.     CurrentSystem = GetClip(System || x)
  60.     if CurrentSystem ~= TargetSystem then do
  61.         PortName = 'LINEMAN.' || x              /* Assemble the port name */
  62.         if show('P', PortName) then do          /* See if the port exists */
  63.             address value PortName              /* Modify host address */
  64.             'SETLINE 1 SYSNAME=' || TargetSystem
  65.             if rc = 0 then
  66.                 Call SetClip(System || x, TargetSystem)
  67.             end
  68.         end
  69.     end
  70.         
  71.  
  72. /*******************************************************/
  73. /*  Determine if changeover was completely successful  */
  74. /*******************************************************/
  75.  
  76. do x=1 to NumLines
  77.     CurrentSystem = GetClip(System || x)
  78.     if CurrentSystem ~= TargetSystem then do
  79.         exit "1 'In Transition'"       
  80.     end
  81.  
  82. /*****************************************************************/
  83. /*  Transition was successful.  Reckon time till next changeover */
  84. /*****************************************************************/
  85.     CurrentDay = Date('w')              /* Retrieve day of week */
  86.     CurrentTime = Time('m')             /* Retrieve minutes since midnight */
  87.  
  88. if TargetSystem = DaySystem then do
  89.     Call SetClip(TargetSystem, NightSystem)     /* Prepare to go to night */
  90.     
  91.     Hours = GoToNight % 100
  92.     Minutes = GotoNight // 100
  93.     Minutes = Minutes + (Hours * 60)
  94.     Delta = Minutes - CurrentTime
  95.     exit Delta "'Waiting->Night'"
  96.     
  97.     end
  98. else do
  99.     Call SetClip(TargetSystem, DaySystem)       /* Prepare to go to day */
  100.  
  101.     Hours = GoToDay % 100
  102.     Minutes = GotoDay // 100
  103.     Minutes = Minutes + (Hours * 60)
  104.     Delta = 1440 - CurrentTime + Minutes
  105.     
  106.     if CurrentDay = 'Friday' then               /* Compensate for weekend */
  107.         Delta = Delta + 2880
  108.     else if CurrentDay = 'Saturday' then
  109.         Delta = Delta + 1440
  110.     
  111.     exit Delta "'Waiting->Day'"
  112.  
  113.     end
  114.